package com.kws.system.controller.Payment;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kws.common.core.domain.R;
import com.kws.system.domain.payment.info.QueryDivisionRuleInfo;
import com.kws.system.domain.payment.rq.CreateDivisionRuleRq;
import com.kws.system.domain.payment.rq.QueryDivisionRuleRq;
import com.kws.system.domain.payment.rq.UpdateDivisionRuleRq;
import com.kws.system.service.payment.DivisionRuleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <b>DivisionRuleController</b>
 *
 * @description: DivisionRuleController <br>
 * @date: 2024/11/25 16:04 <br>
 * @author: lhm <br>
 * @version: 1.0 <br>
 */

@Api(tags = "分账规则")
@RestController
public class DivisionRuleController {
    private static final Logger logger = LoggerFactory.getLogger(DivisionRuleController.class);

    @Autowired
    private DivisionRuleService divisionRuleService;

    @ApiOperation("分页查询分账规则列表")
    @PostMapping("/query/divisionRule/page")
    public R<Page<QueryDivisionRuleInfo>> queryDivisionRulePage(@RequestBody QueryDivisionRuleRq rq){
        Page<QueryDivisionRuleInfo> pageInfo = divisionRuleService.queryDivisionRulePage(rq);
        return R.ok(pageInfo);
    }

    @ApiOperation("新增分账规则")
    @PostMapping("/create/divisionRule")
    public R createDivisionRule(@RequestBody CreateDivisionRuleRq rq){
        boolean status = divisionRuleService.createDivisionRule(rq);
        return R.ok(status);
    }

    @ApiOperation("根据规则ID查询规则详情")
    @GetMapping("/query/divisionRule/byId")
    public R queryDivisionRuleById(@RequestParam Long id){
        QueryDivisionRuleInfo info = divisionRuleService.queryDivisionRuleById(id);
        return R.ok(info);
    }

    @ApiOperation("根据规则id修改规则消息")
    @PostMapping("/update/divisionRule")
    public R updateDivisionRule(@RequestBody UpdateDivisionRuleRq rq){
        boolean status = divisionRuleService.updateDivisionRule(rq);
        return R.ok(status);
    }

    @ApiOperation("根据规则ID删除规则信息")
    @GetMapping("/delete/divisionRule/byId")
    public R deleteDivisionRuleById(@RequestParam Long id){
        boolean status = divisionRuleService.deleteDivisionRuleById(id);
        return R.ok(status);
    }
}
